package com.example.myapplication;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.ProgressBar;

import java.util.List;

public class RateListActivity extends AppCompatActivity {
    private static final String TAG="ratelist";
    Handler handler;
    private ProgressBar bar;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rate_list);
        ListView mylist=findViewById(R.id.mylistview);

        String[] data={"one","two","three","测试数据"};
        ListAdapter adapter=new ArrayAdapter<String>(RateListActivity.this, android.R.layout.simple_expandable_list_item_1,data);
        mylist.setAdapter(adapter);
        bar=findViewById(R.id.progressBar);

        handler=new Handler(){
            @Override
            public void handleMessage(@NonNull Message msg) {
                if(msg.what==5){
                    List<String> list=(List<String>) msg.obj;
                    ListAdapter adapter=new ArrayAdapter<String>(RateListActivity.this, android.R.layout.simple_expandable_list_item_1,list);
                    mylist.setAdapter(adapter);
                }
                super.handleMessage(msg);
            }
        };
        MyTask myTask=new MyTask();
        myTask.setHandler(handler);

        Thread t=new Thread(myTask);
        t.start();
    }
}